﻿using MHI.DeviceManager.Interfaces;
using MHI.DeviceManager.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebFoundation;
using WebFoundation.Data;

namespace MHI.DeviceManager.Business
{
    internal class DeviceModule : WFModule, IDeviceModule
    {
        private DbManager _dbManager;
        private readonly DevDevicemaintenanceTQueryDAO _devMaintenanceQueryDAO;
        private readonly DevDevicemaintenanceTWritingDAO _devMaintenanceWriteDAO;
        private readonly DevDeviceTQueryDAO _devDeviceQueryDAO;
        private readonly DevDeviceTWritingDAO _devDeviceWriteDAO;
        private readonly DevLocationinfoTQueryDAO _devLocationinfoTQueryDAO;
        private readonly DevLocationinfoTWritingDAO _devLocationinfoTWriteDAO;

        public DeviceModule()
        {
            _dbManager = DbManager.FromConfig();
            _devMaintenanceQueryDAO = new DevDevicemaintenanceTQueryDAO(_dbManager);
            _devMaintenanceWriteDAO = new DevDevicemaintenanceTWritingDAO(_dbManager);
            _devDeviceQueryDAO = new DevDeviceTQueryDAO(_dbManager);
            _devDeviceWriteDAO = new DevDeviceTWritingDAO(_dbManager);
            _devLocationinfoTQueryDAO = new DevLocationinfoTQueryDAO(_dbManager);
            _devLocationinfoTWriteDAO = new DevLocationinfoTWritingDAO(_dbManager);

            this.Locations = new DevLocationinfoTList(_devLocationinfoTQueryDAO, _devLocationinfoTWriteDAO, this);
            this.Devices = new DevDeviceTList(_devDeviceQueryDAO, _devDeviceWriteDAO, this);
            this.DeviceMaintenances = new DevDevicemaintenanceTList(_devMaintenanceQueryDAO, _devMaintenanceWriteDAO, this);
        }

        public IDevLocationinfoTList Locations
        {
            get;
            private set;
        }

        public IDevDeviceTList Devices
        {
            get;
            private set;
        }

        public IDevDevicemaintenanceTList DeviceMaintenances
        {
            get;
            private set;
        }
    }
}
